package com.md24housecall.model;

import java.util.ArrayList;

import android.os.Parcel;
import android.os.Parcelable;

public class TagCategory implements Parcelable {

	public String _name;
	public ArrayList<TagItem> _items;
	
	public TagCategory() {
		_name = "";
		_items = new ArrayList<TagItem>();
	}
	
	/** Constructor with data from Parcel */
	public TagCategory(Parcel in) {
		this._name = in.readString();
		this._items = new ArrayList<TagItem>();
		in.readList(_items, null);
	}
	
	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeString(_name);
		dest.writeList(_items);
	}
	
	public static final Parcelable.Creator<TagCategory> CREATOR = new Parcelable.Creator<TagCategory>() {
		public TagCategory createFromParcel(Parcel in) {
			return new TagCategory(in); 
		}
		public TagCategory[] newArray(int size) {
			return new TagCategory[size];
		}
	};
	
	@Override
	public String toString() {
		return _name + ", " + _items.toString();
	}
	public boolean isEmpty() {
		return _items == null || _items.isEmpty();
	}
	@Override
	public int describeContents() {
		// TODO Auto-generated method stub
		return 0;
	}
	
	public void addTag(TagItem item) {
		if(_items == null)
			_items = new ArrayList<TagItem>();
		_items.add(item);
	}
	
}
